/*************************************************************************
	> File Name: orphan.c
	> Author: Angel Criss
	> Blog: blog.abbycin.tk 
	> Created Time: Tue 08 Jul 2014 11:03:03 AM CST
 ************************************************************************/

#include"head.h"

int main(int argc,char *argv[])
{
    pid_t orphan;

    switch(orphan=fork())
    {
        case -1:
            err("fork");
        case 0:
            printf("(orphan) PID: \e[36m%d\e[0m\n",getpid());
            for(;;)
                sleep(1); // a infinity loop for orphan process
        default:
            sleep(3); // let child process runs for a while
            printf("created an orphan process\nand the orphan has reaped by \e[44minit\e[0m\n");
            exit(EXIT_SUCCESS);
    }
}
